package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */

class UserNameException extends Exception{
    public UserNameException(String message) {

        super(message);
    }
    public UserNameException(String message, Throwable cause) {
        super(message, cause);
    }
}
class PasswordException extends Exception{
    public PasswordException(String message) {

        super(message);
    }
    public PasswordException(String message, Throwable cause) {
        super(message, cause);
    }
}

public class  Text{
    private String name="lishi";
    private String password="123";
    public void login(String name,String password)throws PasswordException,UserNameException{
        if (!this.name.equals(name)){
            throw new UserNameException("用户名错误.....");
        }
        if (!this.password.equals(password)){
            throw new PasswordException("密码错误......");
        }
        System.out.println("登录成功");
    }
    public static void main(String[] args) {
        try {
            Text text =new Text();
            text.login("lishi","123");
        }catch (PasswordException e){
            e.printStackTrace();
        }catch (UserNameException e){
            e.printStackTrace();
        }
    }
}

